let arr = [1,2,3,4,5,4,3,2,1];
//1. 数组去重
let result1 = new Set(arr); //此时result是一个集合,转化为数组只需要使用扩展运算符展开
console.log(result1); // { 1, 2, 3, 4, 5 }


let result2 = [...new Set(arr)];
console.log(result2); // [ 1, 2, 3, 4, 5 ]

